home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 22 / Amiga Format AFCD22 (Jan 1998, Issue 106).iso / -in_the_mag- / converters / graphics / netpbm / ppmtoinfo / ppmtoinfo.readme < prev    next >
Text File  |  1997-11-16  |  5KB  |  135 lines

  1. Description: Utility to convert ppm images to .info files.
  2. Short: Utility to convert ppm images to .info files.
  3. Keywords: amiga graphics workbench icon, info, ppm
  4. Author: mheinz@ssw.com (Michael Heinz)
  5. Uploader: mheinz@ssw.com (Michael Heinz)
  6.  
  7. + This utility converts ppm images to .info files.
  8.  
  9. COPYRIGHT
  10.  
  11.     COPYRIGHT 1994 Michael W. Heinz, Sr.  All Rights Reserved.
  12.     This application is freely distributable, provided that all 
  13.     documentation is included.
  14.  
  15. NOTES
  16.  
  17. Introduction:
  18.  
  19.     One of my all time favorite utilities was "iconize".  Written in 1990,
  20.     iconize would read an ILBM image and scale it into an Amiga WB icon.
  21.     Unfortunately, it only used one palette - and if your WB didn't use it, 
  22.     the icons would look very strange.
  23.  
  24.     I'm also a big fan of the PBM/PPM set of tools.  These tools, written 
  25.     for UNIX systems are easily ported to the Amiga and provide some 
  26.     powerful image conversion and processing tools, even if they have 
  27.     absolutely no user interface.
  28.  
  29.     Combining these two ideas, I came up with PPMTOINFO.  PPMTOINFO 
  30.     converts a PPM formatted image into a WorkBench icon file.  For it to be 
  31.     useful, you will also need the ppm tools (the latest version is called 
  32.     "netpbm" and can be found on the aminet.)
  33.  
  34. Usage:
  35.  
  36.     ppmtoinfo [-tool {default tool}] 0[-tooltype {tool type}]10 
  37.                 -map {mapfile} -icon {iconfile} [{ppmfile}]
  38.  
  39.     In it's simplest form, ppmtoinfo takes three arguments - the name of 
  40.     the ppm file to convert, the name of the ppm file holding the palette 
  41.     and the name of the icon to create.  (.info will be added to the name 
  42.     automagically.)
  43.  
  44.     If -tool is provided, it will be used to set the default tool of the 
  45.     icon. If one or more -tooltype records are provided, they can be used 
  46.     to set the tool types of the icon.  Up to 10 -tooltype records are 
  47.     supported.
  48.  
  49.     The ppmfile (the image to be converted) should be in the P6 format 
  50.     used by standard ppm commands.  It should be scaled to the desired 
  51.     size of the icon, because the icon will be the same size as the 
  52.     original image.  If the ppmfile is not specified in the command line,
  53.     it will be read from the standard input.  This conforms to the usual
  54.     operation of a PPM utility.
  55.  
  56.     The map file is needed because all PPM images are "true color" - they 
  57.     don't use palettes.  The map file is defined in the P3 format and shows 
  58.     the palette, 1 pixel per color.  For example, here is the palette for a 
  59.     standard MagicWB arrangement:
  60.  
  61.     P3
  62.     8 1
  63.     255 
  64.     144 144 144
  65.     0 0 0 
  66.     240 240 240
  67.     80 112 160
  68.     128 128 128
  69.     160 160 160
  70.     160 144 128
  71.     224 160 144
  72.  
  73.     Notice that the colors go from 0 to 255, rather than from 0 to 16.  
  74.     Just multiply your regular palette by 16.  Note also that the palette 
  75.     must include every color present in the original image.  ppmtoinfo 
  76.     makes no attempt to dither or remap the original image - it just 
  77.     translates it into a .info file.  (You'll see why in a minute.)
  78.  
  79.     Typically, you will use this tool in combination with other ppm utilities 
  80.     and tools (For example, djpeg converts jpg images to ppm format.)
  81.  
  82.     So say I wanted to create an icon for a jpg file called "dragonglass".  
  83.     I would perform the following steps:
  84.  
  85.     1.    Convert the jpg to a ppm file:                
  86.                 djpeg dragonglass.jpg dg.ppm
  87.     2.    Scale the ppm file to icon size:
  88.                 pnmsize -xsize 64 dg.ppm >small.ppm
  89.     
  90.         (note that I only specify the size in the x axis.  This allows 
  91.         pnmsize to scale the y axis mathematically to give the icon
  92.         the same appearance as the original image.)
  93.     
  94.     3.    Recolor the ppm file to match your WorkBench:
  95.                 ppmquant -fs -map wb_map.ppm small.ppm >icon.ppm
  96.     
  97.     4.    Convert the ppm file to an icon:
  98.                 ppmtoinfo <icon.ppm -map wb_map.ppm -icon DragonGlass.jpg \
  99.                         -tool RetinaDisplay
  100.  
  101.     The result will be a new icon called "DragonGlass.jpg.info".  Note that
  102.     the palette file used in step 4 is the same one used to re-color the
  103.     image in step 3.  This is why ppmtoinfo doesn't provide built-in 
  104.     recoloring or dithering capabilities - ppmquant already does an
  105.     excellent job.
  106.  
  107.     To simplify the conversion process, you can use the following script,
  108.     which converts iff images to icons of the same name:
  109.  
  110.     MAKEICON
  111.     
  112.     .key file/a,opt/f
  113.     .bra {
  114.     .ket }
  115.  
  116.     echo "Converting {file} to an icon.  Opts: {opt}"
  117.     run ilbmtoppm "{file}" >pipe:mi_a
  118.     run pnmscale >pipe:mi_b -xsize 64 pipe:mi_a
  119.     run ppmquant >pipe:mi_c -fs -map pbm:wb_map.ppm pipe:mi_b
  120.     ppmtoinfo <pipe:mi_c {opt} -map pbm:wb_map.ppm -icon "{file}" 
  121.  
  122.     You can use the "SPAT" script (found in your s: directory) to automatically
  123.     build icons for all the images in a directory.  For example:
  124.     
  125.     SPAT makeicon ~(#?.info) -tool RetinaDisplay
  126.     
  127. DISCLAIMER
  128.  
  129.     Works on my machine!
  130.  
  131. Michael Heinz
  132. (mheinz@ssw.com)
  133.  
  134.  
  135.